using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Batch.Dto;
using JTZY.Model.Batch;
using JTZY.Service.Batch.IBatchService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2025-03-05
namespace JTZY.Admin.WebApi.Controllers.Batch
{
    /// <summary>
    /// 批量发货明细
    /// </summary>
    [Verify]
    [Route("batch/Batchshipitem")]
    public class BatchshipitemController : BaseController
    {
        /// <summary>
        /// 批量发货明细接口
        /// </summary>
        private readonly IBatchshipitemService _BatchshipitemService;

        public BatchshipitemController(IBatchshipitemService BatchshipitemService)
        {
            _BatchshipitemService = BatchshipitemService;
        }

        /// <summary>
        /// 查询批量发货明细列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "batchshipitem:list")]
        public IActionResult QueryBatchshipitem([FromQuery] BatchshipitemQueryDto parm)
        {
            var response = _BatchshipitemService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询批量发货明细详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "batchshipitem:query")]
        public IActionResult GetBatchshipitem(long Id)
        {
            var response = _BatchshipitemService.GetInfo(Id);
            
            var info = response.Adapt<BatchshipitemDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加批量发货明细
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "batchshipitem:add")]
        [Log(Title = "批量发货明细", BusinessType = BusinessType.INSERT)]
        public IActionResult AddBatchshipitem([FromBody] BatchshipitemDto parm)
        {
            var modal = parm.Adapt<Batchshipitem>().ToCreate(HttpContext);

            var response = _BatchshipitemService.AddBatchshipitem(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新批量发货明细
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "batchshipitem:edit")]
        [Log(Title = "批量发货明细", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateBatchshipitem([FromBody] BatchshipitemDto parm)
        {
            var modal = parm.Adapt<Batchshipitem>().ToUpdate(HttpContext);
            var response = _BatchshipitemService.UpdateBatchshipitem(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除批量发货明细
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "batchshipitem:delete")]
        [Log(Title = "批量发货明细", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteBatchshipitem([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_BatchshipitemService.Delete(idArr));
        }

    }
}